Programming Language:
    Complex Numbers | Linear Algebra | Fit Algorithms | Interpolation | Root Finding | ODE | FFT | Special Functions | Integration

    ROOT FINDING AND MINIMIZING OF FUNCTIONS

    - tools for root finding and minimizing in Xi -

    The purpose of find_root(func,x[,tol][,fcn_calls]) is to calculate a zero of a given function func next to an initial estimation x of the solution vector (double). The algorithm will be terminated if the relative error between x and the solution is at most tol. The optional parameter fcn_calls is used to lay down the maximum number of calls to func within an iteration. As a simple example we evaluate the zeros of the polynom 4*x^2-3*x-10:
    (  1)>double [] f(double x[]) {return 4*pow(x,2)-3*x-10;}
    Function f defined
    (  2)>[x,f]=find_root([x->z:z=f(x);],{-1,1});
    Message: algorithm estimates that the relative error between x and the solution
    is at most tol in function find_root
    (  3)>print(x,f);
    <dblarr> 
    -1.25     2
    <dblarr>
    -2.9345415e-12 -5.1318949e-12
    
    Checking this result yields
    (  4)>print(f(x));
    
    -2.9345415e-12 -5.1318949e-12
    

    The purpose of minimize(func,x[,tol][,fcn_calls]) is to minimize the sum of the squares of the nonlinear function func (double vector), where x contains an initial estimate of the solution vector. tol is a tolerance parameter: termination of the routine occurs when the algorithm estimates either that the relative error in the sum of squares is at most tol or that the relative error between x and the solution is at most tol. fcn_calls lays down the maximum number of calls to func within an iteration.

    Example: minimize the function f(x,y)={cos(x),exp(-x^2)}.

    (  1)>double[] f(double x[]) {return {cos(x),exp(-x*x)};}
    Function f defined
    (  2)>[x,f]=minimize([x->y:y=f(x);],{1},\fcn_calls=1000)
    Message: algorithm estimates that the relative error between x and the solutionis at most tol in function minimize
    (  3)>print(x,f);
    
    1.5909477 
    
    -0.020149981   0.07957029 
    


    Rechts Index Index Index Linls © 1995 by Bodo Junglas, Klaus Spanderen and Fabian Weis
    - Last revised: April 23 1996